package com.dream.domain.user;

import com.dream.domain.DomainObject;
import com.dream.domain.article.Article;
import com.dream.domain.resume.Resume;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: Gang Zhong
 * Date: 13-3-15
 * Time: 上午1:26
 */
public class User extends DomainObject implements UserDetails {
    private String username;
    private String password;
    private String nickname;
    private String email;
    private List<Article> articles = new ArrayList<Article>();
    private Resume resume;

    public User() {
    }

    public User(String username, String password, String nickname, String email) {
        this.username = username;
        this.password = password;
        this.nickname = nickname;
        this.email = email;
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return Collections.emptyList();
    }

    @Override
    public String getPassword() {
        return this.password;
    }

    @Override
    public String getUsername() {
        return this.username;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return this.active();
    }

    public String getNickname() {
        return nickname;
    }

    public String getEmail() {
        return email;
    }
}
